﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Data.SqlClient;


namespace VerdePimienta2._0
{
    public partial class ListadoEmpresas : Form
    {
        string constring = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\VP\\des_VP.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
        //string constring = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\VP\\verdepimientadb.mdf;Integrated Security=True;User Instance=True";
        public ListadoEmpresas()
        {
            InitializeComponent();
        }

        private void empresasBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.empresasBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.verdepimientadbDataSet);

        }

        private void ListadoEmpresas_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'verdepimientadbDataSet.Empresas' table. You can move, or remove it, as needed.
            //this.empresasTableAdapter.Fill(this.verdepimientadbDataSet.Empresas);

            SqlConnection c = new SqlConnection(constring);
            c.Open();
            SqlDataAdapter da = new SqlDataAdapter("Select * from Clientes where Tipo = 'Empresa'", c);
            DataSet ds = new DataSet("Clientes");
            da.FillSchema(ds, SchemaType.Source, "Clientes");
            da.Fill(ds, "Clientes");
            DataTable dt = ds.Tables["Clientes"];
            
            empresasDataGridView.DataSource = ds.Tables["Clientes"].DefaultView;

        }
    }
}
